package com.yanqu.road.entity.activity.lottery;

import com.yanqu.road.entity.DataObject;
import com.yanqu.road.entity.FieldTypeAnnotation;

import java.util.HashMap;
import java.util.Map;

@FieldTypeAnnotation(tableName = "t_u_activity_lottery_user_data", desc = "通用抽奖")
public class UserActivityLotteryData extends DataObject {

    @FieldTypeAnnotation(desc = "活动ID", select = true, update = true)
    private int activityId;

    @FieldTypeAnnotation(desc = "皮肤类型", select = true, update = true)
    private int lotteryType;

    @FieldTypeAnnotation(desc = "用户ID", select = true, update = true)
    private long userId;

    @FieldTypeAnnotation(desc = "总抽盲盒次数")
    private int totalDrawTimes;

    @FieldTypeAnnotation(desc = "距上次抽中隐藏款的次数-会重置")
    private int commonDrawTimes;

    @FieldTypeAnnotation(desc = "上次奖励")
    private int lastDrawItem;

    @FieldTypeAnnotation(desc = "已抽取奖励")
    private Map<Integer, Integer> getItemMap = new HashMap<>();

    @FieldTypeAnnotation(desc = "是否中共享大奖")
    private boolean getSharedBox;
    @FieldTypeAnnotation(desc = "公告已读时间")
    private long noticeReadTime;


    //缓存
    // 上次抽盲盒时间
    private long lastDrawTime;

    public int getActivityId() {
        return activityId;
    }

    public void setActivityId(int activityId) {
        if(this.activityId != activityId) {
            this.activityId = activityId;
            setUpdateOption();
        }
    }

    public int getLotteryType() {
        return lotteryType;
    }

    public void setLotteryType(int lotteryType) {
        if(lotteryType != this.lotteryType){
            this.lotteryType = lotteryType;
            setUpdateOption();
        }
    }

    public long getUserId() {
        return userId;
    }

    public void setUserId(long userId) {
        if(this.userId != userId) {
            this.userId = userId;
            setUpdateOption();
        }
    }

    public int getTotalDrawTimes() {
        return totalDrawTimes;
    }

    public void setTotalDrawTimes(int totalDrawTimes) {
        if(this.totalDrawTimes != totalDrawTimes) {
            this.totalDrawTimes = totalDrawTimes;
            setUpdateOption();
        }
    }

    public int getLastDrawItem() {
        return lastDrawItem;
    }

    public void setLastDrawItem(int lastDrawItem) {
        if(this.lastDrawItem != lastDrawItem) {
            this.lastDrawItem = lastDrawItem;
            setUpdateOption();
        }
    }

    public boolean isGetSharedBox() {
        return getSharedBox;
    }

    public void setGetSharedBox(boolean getSharedBox) {
        if(this.getSharedBox != getSharedBox) {
            this.getSharedBox = getSharedBox;
            setUpdateOption();
        }
    }

    public int getCommonDrawTimes() {
        return commonDrawTimes;
    }

    public void setCommonDrawTimes(int commonDrawTimes) {
        if(this.commonDrawTimes != commonDrawTimes) {
            this.commonDrawTimes = commonDrawTimes;
            setUpdateOption();
        }
    }

    public Map<Integer, Integer> getGetItemMap() {
        return getItemMap;
    }

    public void setGetItemMap(Map<Integer, Integer> getItemMap) {
        if (getItemMap == null) {
            return;
        }
        this.getItemMap = getItemMap;
        setUpdateOption();
    }

    public void addGetItem(int id, int num){
        int old = getItemMap.getOrDefault(id, 0);
        getItemMap.put(id, old + num);
        setUpdateOption();
    }

    public long getLastDrawTime() {
        return lastDrawTime;
    }

    public void setLastDrawTime(long lastDrawTime) {
        this.lastDrawTime = lastDrawTime;
    }

    public long getNoticeReadTime() {
        return noticeReadTime;
    }

    public void setNoticeReadTime(long noticeReadTime) {
        if (this.noticeReadTime != noticeReadTime) {
            this.noticeReadTime = noticeReadTime;
            setUpdateOption();
        }
    }
}
